<script setup>
import { useThemeStore } from '../user/util/color/stores/theme';
import ColorPalette from '../user/util/color/components/ColorPalette.vue';
import SampleComponent from '../user/util/color/components/SampleComponent.vue';

// 必须调用一次 useThemeStore() 来激活 store，确保 watch 生效
const themeStore = useThemeStore();
</script>

<template>
  <div id="app-layout">
    <header class="app-header">
      <h1>Vue 3 全局调色板示例</h1>
      <div class="controls">
        <button @click="themeStore.toggleThemeMode()" class="theme-toggle-button">
          切换到 {{ themeStore.themeMode === 'light' ? '暗色' : '亮色' }}
          ({{ themeStore.themeMode === 'light' ? '🌙' : '☀️' }})
        </button>
        <ColorPalette />
      </div>
    </header>

    <main class="app-content">
      <p>下面的组件样式会随着上方调色板和模式切换而改变。</p>
      <SampleComponent />
      <SampleComponent />
    </main>

    <footer class="app-footer">
      页脚部分 - <a href="#">页脚链接</a>
    </footer>
  </div>
</template>

<style>
/* App.vue 使用 <style> 而不是 <style scoped> 来定义全局布局样式 */
/* 或者将这些样式也放入 theme.css */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  background-color: var(--card-bg-color);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.app-header h1 {
  margin: 0;
  font-size: 1.5em;
  color: var(--text-color-primary);
  /* 让标题也带点主题色 */
  /* border-left: 4px solid var(--primary-color); */
  /* padding-left: 10px; */
}

.controls {
  display: flex;
  align-items: center;
}

.theme-toggle-button {
   background-color: transparent;
   border: 1px solid var(--border-color);
   color: var(--text-color-secondary);
   padding: 8px 12px;
}
.theme-toggle-button:hover {
    background-color: var(--border-color);
    color: var(--text-color-primary);
}


.app-content {
  padding: 30px;
}

.app-footer {
  text-align: center;
  padding: 20px;
  margin-top: 40px;
  border-top: 1px solid var(--border-color);
  color: var(--text-color-secondary);
  font-size: 0.9em;
}
.app-footer a {
    color: var(--text-color-secondary);
    text-decoration: underline;
}
</style>